package com.gugee.ins.common.dal.mapper.statistics;

import com.gugee.common.mapper.GugeeMapper;
import com.gugee.ins.common.model.es.StatisticsData;
import com.gugee.ins.common.model.mysql.statistics.InsStBloggerRace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface InsStBloggerRaceMapper extends GugeeMapper<InsStBloggerRace> {

    @Delete("delete from ins_st_blogger_race where uid = #{uid}")
    void deleteByUid(long uid);

    @Select("SELECT b.race race,count(*) raceRate " +
            "FROM ins_rel_blogger_active_follower ba LEFT JOIN ins_blogger b ON ba.f_uid = b.uid " +
            "WHERE ba.uid = #{uid} GROUP BY  b.race ORDER BY raceRate DESC ")
    List<InsStBloggerRace> findByActiveFollower(long uid);

    @Select("select * from ins_st_blogger_race WHERE uid = #{uid} ORDER BY race_rank ")
    List<InsStBloggerRace> findByUid(long uid);

    @Select("select race `property`,race_rank `rank`,race_rate `value` from ins_st_blogger_race WHERE uid = #{uid} ORDER BY race_rank ")
    List<StatisticsData> findStatisticsDataByUid(long uid);
}